#coding=utf-8
#!/usr/bin/python

count = int(raw_input("count : "))
di_V = [str(i) for i in range(1,count+1)]

di_B = []

for i in range(len(di_V)):
    tem = di_V
    a=['*' for i3 in range(len(di_V))]
    print a
    for i2 in range(i,len(di_V)):
        b = int(raw_input("way distance: "))
        a[i2] = b
    di_B.append(a)

Ri_B = [[i for i in range(len(di_V))] for i2 in range(len(di_V))]

print di_B

for i in range(len(di_B)):
    di_B[i][i] = 0
    for i2 in range(len(di_B)):
        if di_B[i][i2] == '*':
            di_B[i][i2] = di_B[i2][i]
        
for i in di_B:
    position = []
    for item in i:
        if item != '*':
            position.append(i.index(item))
    di_B[position[0]][position[1]] = i[position[0]] + i[position[1]]

for i in di_B:
    print i
